define(['app'], function(app) {
    'use strict';
    //实例化方法
    var factory = function (Http) {
        /**
         * 一键切换数据获取方式
         * @param {Object} result
         */
        function get_data_getoutletlist(result) {
            if (false) {
                result = '{"success": true,"msg": "","result": {"outlet": [{"id": "001","name": "服务1号站","brand": "世达","address": "上大路","contact": "张三","contact_info": "18912345678"},{"id": "002","name": "服务1号站","brand": "世达","address": "上大路","contact": "张三","contact_info": "18912345678"}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
               return JSON.parse(result);;
            }
            else {
                return result;
            }
        }
        function get_data_publish_brand(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": {"brand": ['+
				'{"id": "001","name": "世达"},'+
				'{"id": "002","name": "博士"}'+
        	']},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
        
        //返回信息
        return {
        	getlist: function (region_id,brand_id,pagelimit,nPage,callback,calldone) {
                Http.post({
                    method: 'info.outlet.getlist', 
                	region_id:region_id,
                	brand_id:brand_id,
                	pagelimit:pagelimit, 
            		nPage:nPage
                }, function (result) {
                    //请求成功
                    if (callback) {
                        callback(get_data_getoutletlist(result).result);
                    }
                }, function (e) {
                    //请求异常
                }, function () {
                    //请求完成，一般不做什么事情
                    if(calldone)
						calldone();
                });
            }, 
            brands: function(callback) {
				Http.post({
						method: 'info.outlet.getbrands',
					},
					function(result) {
						//请求成功
						if(callback)
							callback(get_data_publish_brand(result).result);
					},
					function(e) {
						//请求异常
					},
					function() {
						//请求完成，一般不做什么事情
					});
			}
            
            
        };
    }
    factory.$inject = ['Http'];
    return app.registerService("Salesoutlets", factory);
});